﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using mendian;

namespace DXApplicationTangche.UC.物料管理
{
    public partial class Frm导入预览 : DevExpress.XtraEditors.XtraForm
    {
        public List<DTO物料清单> list = new List<DTO物料清单>();
        private string catalogId;
        public Frm导入预览()
        {
            InitializeComponent();
        }
        public Frm导入预览(List<DTO物料清单> list,string catalogId, List<DTO物料清单> list物料清单)
        {
            InitializeComponent();
            this.list = list;
            this.catalogId = catalogId;
            if (list物料清单.Count > 0)
            {
                foreach (DTO物料清单 dto in list物料清单)
                {
                    this.list.Add(new DTO物料清单(dto));
                }
            }
            this.gridControl预览.DataSource = this.list;
        }

        private void simpleButton确认导入_Click(object sender, EventArgs e)
        {
            RestCall.PostHttp(URL.接口url + "/material/saveAccessoryMaterialList?catelogId=" + this.catalogId + "&vender_id=" + "", FunctionHelper.JsonSerialization(this.list));
            this.Close();
        }

        private void gridView预览_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
        {
            //foreach (DTO物料清单 dto in this.list)
            //{
            //    if (!String.IsNullOrEmpty(dto.material_id))
            //    {
            //        e.Appearance.BackColor = System.Drawing.Color.Red;
            //    }
            //    else
            //    {
            //        e.Appearance.BackColor = System.Drawing.Color.White;
            //    }
            //}
        }

        private void toolStripMenuItem删除_Click(object sender, EventArgs e)
        {
            int i = this.gridView预览.FocusedRowHandle;
            this.list.Remove(list[this.gridView预览.FocusedRowHandle]);
            this.gridControl预览.DataSource = this.list;
            this.gridView预览.RefreshData(); 
        }
    }
}